package com.sayimo.maker.activity.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import com.sayimo.framework.exception.DaoException;
import com.sayimo.framework.exception.ServiceException;
import com.sayimo.maker.activity.dao.BaseActivityDao;
import com.sayimo.maker.activity.service.BaseActivityService;
import com.sayimo.maker.commons.Constant;

/**
 * @Copyright (c) 2016 广东省尚一互联网有限公司
 * @Project: schoolmallapi1.1.0
 * @ClassName: BaseActivityServiceImpl
 * @Description: 
 * @Author:	李强
 * @Date:	日期：2016年5月12日  时间：下午6:10:23
 * @Version 1.0.0
 */
@Service(value="baseActivityService")
public class BaseActivityServiceImpl implements BaseActivityService{
	
	@Autowired
	private BaseActivityDao baseActivityDao;
	
	/**
	 * 根据标示符查询活动信息
	 */
	@Override
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public Map selectBaseActivityIdentifier(String identifier)
			throws ServiceException {
		Map resultMap = new HashMap();
		if(StringUtils.isEmpty(identifier)){//参数错误
			resultMap.put(Constant.STATUS, Constant.STATUS_ERROR);
			resultMap.put(Constant.ERROR, Constant.SYSTEM_REQUEST_PARAM_ERROR);
			return resultMap;
		}
		Map map=new HashMap();
		try {
			map=baseActivityDao.selectBaseActivityIdentifier(identifier);
			resultMap.put(Constant.DATA, map);
			resultMap.put(Constant.STATUS, Constant.STATUS_SUCCESS);
		} catch (DaoException e) {
			e.printStackTrace();
		}
		return resultMap;
	}

	@Override
	public Map queryAllBaseActivity() throws ServiceException {
		// TODO Auto-generated method stub
		Map resultMap = new HashMap();
		try {
			List list = baseActivityDao.queryAllBaseActivity();
			resultMap.put(Constant.DATA, list);
			resultMap.put(Constant.STATUS, Constant.STATUS_SUCCESS);
		} catch (DaoException e) {
			throw new ServiceException(e);
		}
		return resultMap;
	}

}
